/**
* AutoSWF - Cody Cushing. March 26, 2009
* Copyright (c) 2009 Cody Cushing
* No use restrictions. Maintain this notice in all versions. 
**/

package com.autoswf.taskrunner.loadtasks
{
	import com.autoswf.taskrunner.IRequest;
	
	
	/**
	 * Object for requesting some type of data or image, can function like a responder using the 
	 * completeHandler and errorHandler callbacks, or "data" property can be directly accessed. 
	 */	
	public class LoadRequest implements IRequest
	{
		/** Uses uri as the id for task runner reference. */
		public function get id():String
		{
			return _uri;
		}
		
		/** The uri of the feed/asset. */
		protected var _uri:String;
		public function get uri():String
		{
			return _uri;
		}
		
		/** The type of feed or asset to load. */
		protected var _type:String;
		public function get type():String
		{
			return _type;
		}
		
		
		/** An optional callback to invoke on success. The LoadRequest is passed as an argument. */
		protected var _completeHandler:Function;
		public function get completeHandler():Function
		{
			return _completeHandler;
		}
		
		/** An optional callback to invoke on failure. The LoadRequest is passed as an argument. */
		protected var _errorHandler:Function;
		public function get errorHandler():Function
		{
			return _errorHandler;
		}
		
		/** The result of the task. */
		protected var _result:*;
		public function set result(value:*):void
		{
			_result = value;
		}
		public function get result():*
		{
			return _result;
		}
		
		
		/**
		 * Constructor.
		 * 
		 * A common Loader is used for string types of: "image", "jpg", "png", "gif", "swf", 
		 * "loader" or if the Loader class def is passed. A URLLoader is used for types of: 
		 * "xml", "string", "urlloader" or if the URLLoader class def is passed.
		 */		
		public function LoadRequest(uri:String, type:Object, completeHandler:Function = null, errorHandler:Function = null)
		{
			_uri = uri;
			_type = type.toString();
			_completeHandler = completeHandler;
			_errorHandler = errorHandler;
		}
		
		
	}
}